$(function(){
		emailbotton = document.getElementById('emailget');
        emailbotton.onclick=function () {
		    email = document.getElementsByName("email")[0];
			emailadress=email.value;
			$.ajax(
			    url='/email/'+emailadress+"/",
				type='GET',
				success=function (data) {
			        if (data.msg=="ok"){
			            alert("邮件发送成功")
					}else {
			            alert("邮件发送失败")
					}

                }
			)
        };
		var btlogin = document.getElementsByName("submit")[0];
		btlogin.onsubmit=function(){
			var loginaccount = document.getElementsByName("useraccount")[0].value;
			var username =document.getElementsByName("username")[0].value;
			var pwd = document.getElementsByName("password")[0].value;
			var checkpwd = document.getElementsByName("trypassword")[0].value;
			var email = document.getElementsByName("email")[0].value;
			var yzm = document.getElementsByName("yzm")[0].value;
			if (loginaccount.length==0){
				alert("登录名不能为空")
				return
			}else if (loginaccount.length<=6){
				alert("登录名过短")
				return
			}else if (loginaccount.length>=16){
				alert("登录名过长")
				return
			}
			if (username.length==0){
				alert("用户名不能为空")
				return
			}
			if (pwd.length==0){
				alert("登录名不能为空")
				return
			}else if (pwd.length<=8){
				alert("密码过短")
				return
			}else if (pwd.length>=16){
				alert("密码过长")
				return
			}
			if(pwd!=checkpwd){
				alert("密码不同")
				return
			}
			if(email.length==0){
				alert("请输入邮箱")
				return
			}else if (yzm.length==0){
				alert("请输入验证码")
				return
			}
			// var formData = new FormData($('input[name="myform"]')[0]);
			// var xhr = null;
			// try{
			// 	xhr = new XMLHttpRequest();
			// }catch(e){
			// 	xhr = new ActiveXObject("Microsoft.XMLHTTP");
			// }
			// xhr.open("POST","/register.html/",true);
			// xhr.send(formData);
			// xhr.onreadystatechange = function(){
			// 	if(xhr.readyState == 4){
			// 		if(xhr.status == 200){
			// 			result=xhr.responseText;
			// 			alert(result)
			// 			var object = eval("("+result+")");
			// 			alert(object.status)
			// 			if(object.status==200){
			// 				alert(object.name+"注册成功")
			// 				window.location.href="/index.html/"
			// 			}else if(object.status==121){
			// 				alert(object.name+"登录名已被注册")
			// 			}else if(object.status==122){
			// 				alert("邮箱或验证码错误")
			// 			}
			// 		}
			// 	}
			// }
		}
	})